//
//  ViewController.m
//  UI25_GCD
//
//  Created by dllo on 16/8/18.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self createSerialQueue];
//    [self createConcurrent];
}
// 串行GCD
- (void)createSerialQueue {
    // 名字 类型
    dispatch_queue_t serial = dispatch_queue_create("mySerial", DISPATCH_QUEUE_SERIAL);
    dispatch_async(serial, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"1 begin");
        NSLog(@"1 end");
    });

    dispatch_async(serial, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"2 begin");
        NSLog(@"2 end");
    });

    dispatch_async(serial, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"3 begin");
        NSLog(@"3 end");
    });

    dispatch_async(serial, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"4 begin");
        NSLog(@"4 end");
    });
}

// 并发
- (void)createConcurrent {
    dispatch_queue_t conCurrent = dispatch_queue_create("mySerial", DISPATCH_QUEUE_CONCURRENT);
    dispatch_async(conCurrent, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"1 begin");
        NSLog(@"1 end");
    });
    
    dispatch_async(conCurrent, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"2 begin");
        NSLog(@"2 end");
    });
    
    dispatch_async(conCurrent, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"3 begin");
        NSLog(@"3 end");
    });
    
    dispatch_async(conCurrent, ^{
        NSLog(@"%@", [NSThread currentThread]);
        NSLog(@"4 begin");
        NSLog(@"4 end");
    });




}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
